/*
 * trace_CmdPathInfo.c
 *
 *  Created on: 2012/07/12
 *      Author: guanxiaoying
 */

#include "../table.h"
#include "../trace_cmd_table.h"
typedef struct _CMDPATHINFO
{
	UCHAR condition;
	UCHAR times;
	UCHAR totalTimes;
	UCHAR broken;
	AST beginNode;
	AST endNode;
	AST pathOut;
	AST pathIn;
	AST pathOut_next;
	AST pathIn_next;
	AST astLoop;
	AST astParam;
} CMDPATHINFO, *PCMDPATHINFO;

#define TableSize  (sizeof(CMDPATHINFO ))
#define TableType  PCMDPATHINFO
#define stTable stCmdPathInfoManager.memoryBlocks
#define maxTable stCmdPathInfoManager.maxRecordNum
#define  maxNumPerBlk  (stCmdPathInfoManager.astMaxNum_Block)


static TABLEMANAGER stCmdPathInfoManager = {
//		U4                  usIdx;
		0,
//		PSZ				    con_pszName;    constant
		__FILE__,
//		U2					con_usSize;		constant
		TableSize,
//		U2					block_num;	　　　　　　　Reset clear  際　要
		0,
//		S4					astMaxNum_Block;     １回設定のみ
		0,
//		S4					astTabNum_LastPage; 　　　　Reset clear  際　要
		0,
//		S4					astMaxNum_LastPage;     Reset clear  際　要
		0,
//		U4					ulMaxByte;	　　　　　　　　　　クリアしない
		0,
//		U4					con_minPageSize;　　　　　　　　　　constant
		0
};
static VOID resetListener( U4  procid, U2 index )
{
	if( procid == stCmdPathInfoManager.u4Idx )
	{
		if( index > 0 && index < MAX_VOLUMN_OF_TABLE )
		{
			stTable[ index-1] = NULL;
		}
	}
}
static TableType core_getTable( AST index )
{
	TableType temp = (TableType)Check_Com( &stCmdPathInfoManager, resetListener,  index );
	if( temp != NULL ){ return &temp[index%maxNumPerBlk]; } return NULL;
}
static BOOL ClearTable( VOID )
{
	return Clear_Com( &stCmdPathInfoManager );
}
static BOOL AllocTable( AST astReqArg )
{
	return AllocTable_Com( &stCmdPathInfoManager, astReqArg, resetListener );
}
static AST getMaxLineNum( VOID ){
	return maxTable;
}
static U2 getPathFlag( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->condition;
}
static U2 setPathFlag( AST astIndex, U2 value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->condition=value;
}
static U2 getTimes( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->times;
}
static U2 setTimes( AST astIndex, U2 value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->times=value;
}
static U2 getTotalTimes( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->totalTimes;
}
static U2 setTotalTimes( AST astIndex, U2 value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->totalTimes=value;
}
static U2 getWhenBroken( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->broken;
}
static U2 setWhenBroken( AST astIndex, U2 value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->broken=value;
}
static AST getBeginNode( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->beginNode;
}
static AST setBeginNode( AST astIndex, AST value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->beginNode=value;
}
static AST getEndNode( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->endNode;
}
static AST setEndNode( AST astIndex, AST value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->endNode=value;
}
static AST getBackwardNode( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->pathIn;
}
static AST setBackwardNode( AST astIndex, AST value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->pathIn=value;
}
static AST getBackwardNextNode( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->pathIn_next;
}
static AST setBackwardNextNode( AST astIndex, AST value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->pathIn_next=value;
}
static AST getForwardNode( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->pathOut;
}
static AST setForwardNode( AST astIndex, AST value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->pathOut=value;
}
static AST getForwardNextNode( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->pathOut_next;
}
static AST setForwardNextNode( AST astIndex, AST value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->pathOut_next=value;
}
static AST getLoopInfo( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astLoop;
}
static AST setLoopInfo( AST astIndex, AST value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astLoop=value;
}
static AST getParam( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astParam;
}
static AST setParam( AST astIndex, AST value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astParam=value;
}
const CMDPATHINFOACCESS stCmdPathInfoAccess={
		ClearTable,
		AllocTable,
		getMaxLineNum,
//		ACCESS_U2_FIELD condition;
//		ACCESS_IDX_FIELD beginNode;
//		ACCESS_IDX_FIELD endNode;
//		ACCESS_IDX_FIELD pathOut;
//		ACCESS_IDX_FIELD pathIn;
//		ACCESS_IDX_FIELD pathOut_next;
//		ACCESS_IDX_FIELD pathIn_next;
		{
				getPathFlag,
				setPathFlag
		},
		{
				getTimes,
				setTimes
		},
		{
				getTotalTimes,
				setTotalTimes
		},
		{
				getWhenBroken,
				setWhenBroken
		},
		{
				getBeginNode,
				setBeginNode
		},
		{
				getEndNode,
				setEndNode
		},
		{
				getForwardNode,
				setForwardNode
		},
		{
				getBackwardNode,
				setBackwardNode
		},
		{
				getForwardNextNode,
				setForwardNextNode
		},
		{
				getBackwardNextNode,
				setBackwardNextNode
		},
		{
				getLoopInfo,
				setLoopInfo
		},
		{
				getParam,
				setParam
		}
};

